package com.sptpc.drink.service.impl;

import com.sptpc.drink.dao.DrinkMapper;
import com.sptpc.drink.pojo.Drink;
import com.sptpc.drink.service.DrinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrinkServiceImpl implements DrinkService {

    @Autowired
    private DrinkMapper drinkMapper;

    @Override
    public Drink queryById(Long id) {
        return drinkMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Drink> queryAll() {
        return drinkMapper.selectAll();
    }

    @Override
    public List<Drink> queryByName(String name) {
        return drinkMapper.selectDrinkByName(name);
    }

    @Override
    public void insert(Drink drink) {
        drinkMapper.insert(drink);
    }

    @Override
    public void delete(Long id) {
        drinkMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Drink drink) {
        drinkMapper.updateByPrimaryKeySelective(drink);
    }
}
